package usecase;

import IUSECASE.IUC_Factory;
import IUSECASE.IUC_GestionClient;
import IUSECASE.IUC_GestionEmployes;
import IUSECASE.IUC_GestionIntervention;
import IUSECASE.IUC_GestionOnSite;
import IUSECASE.IUC_GestionPlanning;
import IUSECASE.IUC_GestionTechniciens;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import run.PublisherImpl;

public class FactoryUC extends PublisherImpl implements IUC_Factory {

    
        //*******************************************************************
        //Constructeur du singleton
        //*******************************************************************

        private static FactoryUC instance;
           
        public static FactoryUC getInstance() throws RemoteException {
                if(instance == null)
                //throw new RuntimeException("One factory must be registered");
                    instance = new FactoryUC();
                return instance;
        }
    
        private FactoryUC() throws RemoteException {
                super();
                //UnicastRemoteObject.exportObject(this,0);
        }

        //*******************************************************************
        //Methodes d'acces
        //******************************************************************* 
    
        public IUC_GestionClient getGestionClients() throws RemoteException {
                return (IUC_GestionClient) GestionClients.getInstance();
        }
    
        public IUC_GestionEmployes getGestionEmployes() throws RemoteException {
                return (IUC_GestionEmployes) GestionEmployes.getInstance();
        }

        public IUC_GestionIntervention getGestionIntervention() throws RemoteException {
                return (IUC_GestionIntervention) GestionInterventions.getInstance();
        }

        public IUC_GestionOnSite getGestionOnSite() throws RemoteException {
                return (IUC_GestionOnSite) GestionOnSite.getInstance();
        }

        public IUC_GestionPlanning getGestionPlanning() throws RemoteException{
                return (IUC_GestionPlanning) GestionPlanning.getInstance();
        }
        
        public IUC_GestionTechniciens getGestionTechniciens() throws RemoteException{
            return (IUC_GestionTechniciens) GestionTechniciens.getInstance();
        }

        public int getNombreConnections() throws RemoteException {
            return this.getNbrSubscribes();
        }
        
        public String getHostServerName() throws RemoteException, UnknownHostException{
            InetAddress Ip =InetAddress.getLocalHost();
            String s1 = Ip.getHostName();
            return s1;
        }
        
        public String getIpServerAddress() throws RemoteException, UnknownHostException{
            InetAddress Ip =InetAddress.getLocalHost();
            String s1 = Ip.getHostAddress();
            return s1;
        }
}